package com.bms.hystrix.service.gllw;

import com.bms.hystrix.interfaces.gllw.ServiceFeignByCheck;
import com.bms.hystrix.pojo.LunWen;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class CheckService {
    @Resource
    private ServiceFeignByCheck serviceFeignByCheck;

    // 通过feign调用服务模块，如果触发熔断机制，则会调用此注解fallbackMethod定义的方法
//    @HystrixCommand(fallbackMethod = "checkError")
//    public Map check(String name) {
//        return serviceFeignByCheck.selectClient(name);
//    }


    public Map<String, Object> lianHeChaXun(String tiMu, String zuoZhe, String faBiaoWeiZhi,
                                            String lunWenLeiBie, Date faBiaoShiJianQiShi, Date faBiaoShiJianJieShu) {
        return serviceFeignByCheck.lianHeChaXun(tiMu,zuoZhe,faBiaoWeiZhi,lunWenLeiBie,faBiaoShiJianQiShi,faBiaoShiJianJieShu);
    }


    public Map<String, Object> chaXunAll() {
        return serviceFeignByCheck.chaXunAll();
    }


    public Map<String, Object> chaXunById(int id) {
        return serviceFeignByCheck.chaXunById(id);
    }



    public Map<String, Object> chaXunCaoGao(int page) {
        return serviceFeignByCheck.chaXunCaoGao(page);
//        return serviceFeignByCheck.chaXunCount(page);
    }


    public Map<String, Object> chaXunByLeiBie(String lunWenLeiBie) {
        return serviceFeignByCheck.chaXunByLeiBie(lunWenLeiBie);
//        return serviceFeignByCheck.chaXunCount(page);
    }



public Map<String, Object> chaXunFenYe(int page) {
    return serviceFeignByCheck.chaXunById(page);
}



    public Map<String, Object> chaXunFenYe01(int page,String tiMu, String zuoZhe,
                                             String faBiaoWeiZhi, String lunWenLeiBie,
                                             String faBiaoShiJianQiShi, String faBiaoShiJianJieShu) {
        return serviceFeignByCheck.chaXunFenYe01(page, tiMu, zuoZhe, faBiaoWeiZhi, lunWenLeiBie,
                faBiaoShiJianQiShi, faBiaoShiJianJieShu);
    }




    public Map<String, Object> gengXinById(LunWen lunWen,HttpServletRequest request, MultipartFile file) {
        return serviceFeignByCheck.gengXinById(lunWen,request,file);
    }


    public Map<String, Object> xiaZai(HttpServletRequest request, HttpServletResponse response, String diZhi){
        return serviceFeignByCheck.xiaZai(request,response,diZhi);
    };


    public Map<String, Object> xinZeng(LunWen lunWen,HttpServletRequest request, MultipartFile file) {
        return serviceFeignByCheck.xinZeng(lunWen,request,file);
    }


    public Map<String, Object> shanChuById(String id) {
        return serviceFeignByCheck.shanChuById(id);
    }


    public Map checkError(String name) {
        Map map = new HashMap();
        map.put("code", 500);
        map.put("msg","服务异常，请稍后重试！");
        map.put("name", name);
        return map;
    }

}
